package com.ohs.ohsoa.utils.bean.responseBean;

import java.io.Serializable;


import lombok.Data;

@Data
public class ResultBean<T> implements Serializable {
	private static final long serialVersionUID = 1L;

	private int success;
	private String msg;
	private String code;
	private String token;
	private T data;


	private ResultBean() {
	}

	private ResultBean(T data) {
		this.success = 1;
		this.data = data;
		this.msg = "success";
	}

	private ResultBean(String msg) {
		this.success = 0;
		this.msg = msg;
	}

	private ResultBean(String code, String msg) {
		this.success = 0;
		this.msg = msg;
		this.code = code;	}

	public static <T> ResultBean<T> success() {
		ResultBean<T> ret = new ResultBean<>();
		ret.success = 1;
		ret.msg = "sucess";		return ret;
	}

	public static <T> ResultBean<T> success(T data) {
		return new ResultBean<>(data);
	}

	public static <T> ResultBean<T> fail(String msg) {
		return new ResultBean<>(msg);
	}

	public static <T> ResultBean<T> fail(String code, String msg) {
		return new ResultBean<>(code, msg);
		
	}
}
